package com.pjbao.app.targetSale.self;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.pjbao.app.targetSale.userInfo.UserInfo;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.logging.Logger;

/**
 * Created by 邱鹏 on 2016/9/29.
 */
@RestController
@RequestMapping("/app/targetSale/")
public class SmsController {
    ObjectMapper mapper = new ObjectMapper();
    Logger logger = Logger.getLogger("[app][targetSale]");

    @Autowired
    SmsService smsService;

    @RequestMapping("sendValidCode")
    public String sendValidCode(HttpServletRequest request, String phone) throws IOException {
        String result = null;
        result = smsService.sendMsg(phone);
        //接收短信验证码，然后存储到redis，点击提交时，检验redis里面和页面上是否一致
        return result;
    }

    @RequestMapping("checkValidCode")
    public String checkValidCode(HttpServletRequest request, UserInfo userInfo, String validCode) throws IOException {
        String result = null;
        result = smsService.checkValidCode(userInfo, validCode);
        //接收短信验证码，然后存储到redis，点击提交时，检验redis里面和页面上是否一致
        return result;
    }
}